package com.feng.common.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Feng
 * @since 2022/4/24 19:50
 */
@Configuration
public class FileConfig implements WebMvcConfigurer {

    public static final  String WRITE_PATH = "D:/feng-upload/";

    public static final  String ACCESS_PATH = "/files/";

    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 进行资源访问映射
        registry.addResourceHandler(ACCESS_PATH + "**").addResourceLocations("file:" + WRITE_PATH);
    }
}
